home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume20 / parseargs / patch07 < prev    next >
Encoding:
Text File  |  1991-07-17  |  13.0 KB  |  321 lines

  1. Newsgroups: comp.sources.misc
  2. From: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  3. Subject:  v20i098:  parseargs - functions to parse command line arguments, Patch07
  4. Message-ID: <1991Jul16.020707.23139@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: df35b50f2b3e5e4092f7f89aa648c0c1
  6. Date: Tue, 16 Jul 1991 02:07:07 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 20, Issue 98
  11. Archive-name: parseargs/patch07
  12. Environment: UNIX, VMS, MS-DOS, OS/2, Amiga
  13. Patch-To: parseargs: Volume 17, Issue 46-57
  14.  
  15. This is patch07 of parseargs. It introduces a few minor changes to parseargs.
  16. They are as follows:
  17.  
  18.     - fixed the "Intro" file to correctly show how to invoke parseargs(3)
  19.       (the arguments where in the wrong order).
  20.     - added stuff in #ifdef UNWRITABLE_STRING_LITERALS to work for machines
  21.       and compilers that dont allow the programmer to modify string literals.
  22.     - documented in the README file, all the various compile-time constants
  23.       that may change the behavior of parseargs.
  24.     - sparseargs neglected to free the argument-vector when it was done
  25.       using it.
  26.  
  27. To apply this patch:
  28.  
  29.     1) cd to your parseargs directory
  30.     2) unshar this file into that directory (this will create the file PATCH07)
  31.     3) type "patch -p0 <PATCH07"
  32.  
  33. ______________________ "And miles to go before I sleep." ______________________
  34.  Brad Appleton                         Harris Corp., Computer Systems Division
  35.    Software Engineer                   2101 West Cypress Creek Road,  M/S 161 
  36.      brad@ssd.csd.harris.com           Fort Lauderdale, FL  33309-1892  USA
  37.        ...!uunet!travis!brad                 Phone: (305) 973-5190
  38. ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
  39.  
  40. #! /bin/sh
  41. # This is a shell archive.  Remove anything before this line, then unpack
  42. # it by saving it into a file and typing "sh file".  To overwrite existing
  43. # files, type "sh file -c".  You can also feed this as standard input via
  44. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  45. # will see the following message at the end:
  46. #        "End of shell archive."
  47. # Contents:  PATCH07
  48. # Wrapped by brad@hcx2 on Mon Jul 15 10:35:04 1991
  49. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  50. if test -f 'PATCH07' -a "${1}" != "-c" ; then 
  51.   echo shar: Will not clobber existing file \"'PATCH07'\"
  52. else
  53. echo shar: Extracting \"'PATCH07'\" \(10057 characters\)
  54. sed "s/^X//" >'PATCH07' <<'END_OF_FILE'
  55. X*** Intro.OLD    Mon Jul 15 10:28:10 1991
  56. X--- Intro    Wed Jun  5 10:38:05 1991
  57. X***************
  58. X*** 73,79 ****
  59. X   Once the above array/string is declared it is a simple matter to invoke
  60. X   parseargs from C as in the following example:
  61. X  
  62. X!     status = parseargs( argdesc_array, argv );
  63. X  
  64. X   or from a shell script as in the following example:
  65. X  
  66. X--- 73,79 ----
  67. X   Once the above array/string is declared it is a simple matter to invoke
  68. X   parseargs from C as in the following example:
  69. X  
  70. X!     status = parseargs( argv, argdesc_array );
  71. X  
  72. X   or from a shell script as in the following example:
  73. X  
  74. X*** README.OLD    Mon Jul 15 10:28:33 1991
  75. X--- README    Fri Jun 21 10:10:30 1991
  76. X***************
  77. X*** 332,338 ****
  78. X   name for shell scripts. Furthermore, I changed the contents of USAGECNTL
  79. X   from a number to a sequence of mnemonic strings (for better readability).
  80. X   I also made USAGECNTL control whether or not a command-description is
  81. X!  printed and whther or not the message is piped to a pager on Unix.
  82. X  
  83. X   Under VMS, the global symbol USAGECNTL is used in lieu of an environment
  84. X   variable.  See the parseargs(3) and parseargs(1) manual pages for more
  85. X--- 332,338 ----
  86. X   name for shell scripts. Furthermore, I changed the contents of USAGECNTL
  87. X   from a number to a sequence of mnemonic strings (for better readability).
  88. X   I also made USAGECNTL control whether or not a command-description is
  89. X!  printed and whether or not the message is piped to a pager on Unix.
  90. X  
  91. X   Under VMS, the global symbol USAGECNTL is used in lieu of an environment
  92. X   variable.  See the parseargs(3) and parseargs(1) manual pages for more
  93. X***************
  94. X*** 360,367 ****
  95. X   Programs that use parseargs may be given default arguments under UNIX
  96. X   and PCs through the use of environment variables (symbols are used for
  97. X   VMS systems). If a C-program or a shell-script uses parseargs to imple-
  98. X!  ment a command named "foo" then the environment variable (or global
  99. X!  synbol) FOO_ARGS will be parsed for any "default" arguments before argv
  100. X   is parsed.  Argv will over-ride any options that are specified in
  101. X   FOO_ARGS (except that ARGLISTs and ARGVECs set in FOO_ARGS will be
  102. X   appended from argv[]).
  103. X--- 360,367 ----
  104. X   Programs that use parseargs may be given default arguments under UNIX
  105. X   and PCs through the use of environment variables (symbols are used for
  106. X   VMS systems). If a C-program or a shell-script uses parseargs to imple-
  107. X!  -ment a command named "foo" then the environment variable (or global
  108. X!  symbol) FOO_ARGS will be parsed for any "default" arguments before argv
  109. X   is parsed.  Argv will over-ride any options that are specified in
  110. X   FOO_ARGS (except that ARGLISTs and ARGVECs set in FOO_ARGS will be
  111. X   appended from argv[]).
  112. X***************
  113. X*** 765,770 ****
  114. X--- 765,797 ----
  115. X   AT&T Unix Systems using both ANSI and non-ANSI C Compilers.
  116. X  
  117. X  
  118. X+  COMPILE-TIME CONSTANTS
  119. X+  ======================
  120. X+  If any of the following macros are #defined at compile time then they will
  121. X+  have the following effect:
  122. X+ 
  123. X+     USE_PAGER    --  for Unix systems only. Parseargs will include the code
  124. X+                      which pipes usage messages to a paging program
  125. X+ 
  126. X+     NOFLOAT      --  Parseargs will NOT include the code for the predefined
  127. X+                      floating point arg-types argFloat() and argDouble().
  128. X+ 
  129. X+     SVR4         --  Parseargs(1) with the -M option will generate the new
  130. X+                      Style Unix manual template.
  131. X+ 
  132. X+     USE_CURSES
  133. X+     USE_TERMINFO
  134. X+     USE_TERMCAP  --  Parseargs will use curses/terminfo/termcap when trying
  135. X+                      to figure out the size of the screen.
  136. X+ 
  137. X+     UNWRITABLE_STRING_LITERALS
  138. X+                  --  This should be used only for compilers and/or machines
  139. X+                      that do NOT allow the programmer to modify the contents
  140. X+                      of string literals such as "hello, world". If this
  141. X+                      constant is #defined, then all modified strings will be
  142. X+                      duplicated (using strdup()) before they are changed.
  143. X+ 
  144. X+ 
  145. X   IBM-PC VERSION OF parseargs(3)
  146. X   ==============================
  147. X   I also added ibm_args.c for MS-DOS and OS/2.
  148. X***************
  149. X*** 794,803 ****
  150. X   ===============================
  151. X   I also added vms_args.c for VAX/VMS.
  152. X  
  153. X!  VMS_ARGS.C HAS NOT BEEN TESTED ON A VMS SYSTEM!!! I did not have one
  154. X!  to test it on. It should accept command-line arguments as described in
  155. X!  the "Grammar Rules" section of the VAX manual but I  cant guarantee
  156. X!  anything so you'll have to test it out for yourself.
  157. X  
  158. X   ARGLIST and ARGVEC are comma-separated lists in the VMS version of
  159. X   parseargs (not whitespace separated lists). In order to preserve a
  160. X--- 821,831 ----
  161. X   ===============================
  162. X   I also added vms_args.c for VAX/VMS.
  163. X  
  164. X!  vms_args.c has been tested by people (other than myself) on a VAX/VMS
  165. X!  system and seems to work okay. It does not use the CLI$XXXXX routines
  166. X!  for parsing. It should accept command-line arguments as described in
  167. X!  the "Grammar Rules" section of the VAX manual with one slight exception
  168. X!  which is noted below.
  169. X  
  170. X   ARGLIST and ARGVEC are comma-separated lists in the VMS version of
  171. X   parseargs (not whitespace separated lists). In order to preserve a
  172. X***************
  173. X*** 890,901 ****
  174. X  
  175. X   Thanx also to Jim Barbour for helping me with some VMS specific things
  176. X   (like getting the original, unparsed command-line from DCL and
  177. X!  retreiving the value of a symbol), and to Tom Christiansen and Raymond
  178. X   Chen for their help in getting parseargs(1) to work for perl scripts.
  179. X  
  180. X!  Thanx also to Gillmer J. Derge, Marco Nijdam, & Chris Johnston for sending
  181. X!  me their bug reports and fixes so that I could incorporate them into the
  182. X!  latest patch of parseargs.
  183. X  
  184. X   Lastly, thanks to all those who use and will continue to improve
  185. X   parseargs, all I ask is that you keep me updated of your efforts (so I
  186. X--- 918,929 ----
  187. X  
  188. X   Thanx also to Jim Barbour for helping me with some VMS specific things
  189. X   (like getting the original, unparsed command-line from DCL and
  190. X!  retrieving the value of a symbol), and to Tom Christiansen and Raymond
  191. X   Chen for their help in getting parseargs(1) to work for perl scripts.
  192. X  
  193. X!  Thanx also to Gillmer J. Derge, Marco Nijdam, Chris Johnston, & Earl Chew
  194. X!  for sending me their bug reports and fixes so that I could incorporate them
  195. X!  into the latest patch of parseargs.
  196. X  
  197. X   Lastly, thanks to all those who use and will continue to improve
  198. X   parseargs, all I ask is that you keep me updated of your efforts (so I
  199. X*** doc/parseargs.man1.OLD    Mon Jul 15 10:30:33 1991
  200. X--- doc/parseargs.man1    Tue Jun 18 17:10:00 1991
  201. X***************
  202. X*** 219,225 ****
  203. X  message printed and execution terminated). Specifying \fB\-1\fP will force
  204. X  all non-positional parameters to precede any positional parameters on the
  205. X  command-line (hence anything on the command-line after a positional parameter
  206. X! that resembles a keyword parameter will nevertheles be interpreted as a
  207. X  positional parameter).
  208. X  .\"----------------------------------------------------------------
  209. X  .so argvalopt.inc
  210. X--- 219,225 ----
  211. X  message printed and execution terminated). Specifying \fB\-1\fP will force
  212. X  all non-positional parameters to precede any positional parameters on the
  213. X  command-line (hence anything on the command-line after a positional parameter
  214. X! that resembles a keyword parameter will nevertheless be interpreted as a
  215. X  positional parameter).
  216. X  .\"----------------------------------------------------------------
  217. X  .so argvalopt.inc
  218. X*** patchlevel.h.OLD    Mon Jul 15 10:32:11 1991
  219. X--- patchlevel.h    Mon Jul 15 10:18:26 1991
  220. X***************
  221. X*** 2,7 ****
  222. X--- 2,18 ----
  223. X  ** ^FILE: patchlevel.h - current patchlevel for parseargs
  224. X  **
  225. X  ** ^HISTORY:
  226. X+ **    06/05/91    Brad Appleton    <brad@ssd.csd.harris.com>
  227. X+ **    Patch07
  228. X+ **    - fixed the "Intro" file to correctly show how to invoke parseargs(3)
  229. X+ **      (the arguments where in the wrong order).
  230. X+ **    - added stuff in #ifdef UNWRITABLE_STRING_LITERALS to work for machines
  231. X+ **      and compilers that dont allow the programmer to modify string literals.
  232. X+ **    - documented in the README file, all the various compile-time constants
  233. X+ **      that may change the behavior of parseargs.
  234. X+ **    - sparseargs neglected to free the argument-vector when it was done
  235. X+ **      using it.
  236. X+ **
  237. X  **    05/11/91    Brad Appleton    <brad@ssd.csd.harris.com>
  238. X  **    Patch06
  239. X  **    - parsecntl(3) now correctly handles mispelled keywords for the
  240. X***************
  241. X*** 80,86 ****
  242. X  
  243. X  #define  VERSION     2
  244. X  #define  REVISION    0
  245. X! #define  PATCHLEVEL  6
  246. X  
  247. X  #ifdef __STDC__
  248. X     static const char
  249. X--- 91,97 ----
  250. X  
  251. X  #define  VERSION     2
  252. X  #define  REVISION    0
  253. X! #define  PATCHLEVEL  7
  254. X  
  255. X  #ifdef __STDC__
  256. X     static const char
  257. X***************
  258. X*** 87,90 ****
  259. X  #else
  260. X     static char
  261. X  #endif
  262. X!    _Ident[] = "@(#)parseargs  2.0  patchlevel 6";
  263. X--- 98,101 ----
  264. X  #else
  265. X     static char
  266. X  #endif
  267. X!    _Ident[] = "@(#)parseargs  2.0  patchlevel 7";
  268. X*** xparse.c.OLD    Mon Jul 15 10:33:49 1991
  269. X--- xparse.c    Wed Jun 19 09:38:14 1991
  270. X***************
  271. X*** 542,547 ****
  272. X--- 542,551 ----
  273. X        if (ARG_isBOOLEAN(ad) || ARG_isPSEUDOARG(ad))
  274. X           BSET( arg_flags(ad), ARGNOVAL );
  275. X  
  276. X+ #ifdef UNWRITABLE_STRING_LITERALS
  277. X+       ad->ad_prompt = strdup( ad->ad_prompt );
  278. X+ #endif
  279. X+ 
  280. X        description = get_description( (char *)arg_sname(ad) );
  281. X        if ( description )  {
  282. X           BSET(arg_flags(ad), ARGDESCRIBED);
  283. X***************
  284. X*** 576,581 ****
  285. X--- 580,589 ----
  286. X     }
  287. X  #endif
  288. X  
  289. X+ #ifdef UNWRITABLE_STRING_LITERALS
  290. X+    cmd_name(argd) = strdup( cmd_name(argd) );
  291. X+ #endif
  292. X+ 
  293. X       /* if new-style, get the purpose from the command name */
  294. X     if ( !old_style  &&  cmd_name(argd) ) {
  295. X        purpose = get_description( (char *)cmd_name(argd) );
  296. X***************
  297. X*** 1881,1886 ****
  298. X--- 1889,1895 ----
  299. X     }
  300. X  
  301. X     rc = parse_argv_style( argv, parse_init( &argd ) );
  302. X+    free( argv );
  303. X  
  304. X        /* scan for missing required arguments */
  305. X     if ( SYNTAX_ERROR(rc, argd) ) {
  306. END_OF_FILE
  307. if test 10057 -ne `wc -c <'PATCH07'`; then
  308.     echo shar: \"'PATCH07'\" unpacked with wrong size!
  309. fi
  310. # end of 'PATCH07'
  311. fi
  312. echo shar: End of shell archive.
  313. exit 0
  314.  
  315. exit 0 # Just in case...
  316. -- 
  317. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  318. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  319. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  320. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  321.